package com.longxi.tianjintianbao.ui.activity.houseinspection;

import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.longxi.tianjintianbao.AppConst;
import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.ui.base.BaseActivity;
import com.longxi.tianjintianbao.ui.presenter.houseinspection.CheckRoomAtPresenter;
import com.longxi.tianjintianbao.ui.view.houseinspection.ICheckRoomAtView;

import butterknife.BindView;

/**
 * 入住验房 检查用
 * Created by cxw on & 2018/9/20
 */
public class CheckRoomActivity extends BaseActivity<ICheckRoomAtView, CheckRoomAtPresenter> implements ICheckRoomAtView {

    @BindView(R.id.tvCheckOver)
    TextView mTvCheckOver;
    @BindView(R.id.etOtherexplain)
    EditText mEtOtherexplain;
    @BindView(R.id.etHygieneexplain)
    EditText mEtHygieneexplain;
    @BindView(R.id.etAmount)
    EditText mEtAmount;
    @BindView(R.id.llRZTZ)
    LinearLayout mLlRZTZ;
    @BindView(R.id.llAmount)
    LinearLayout mLlAmount;

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_check_room;
    }

    @Override
    protected CheckRoomAtPresenter createPresenter() {
        return new CheckRoomAtPresenter(this);
    }

    @Override
    public void initView() {
        super.initView();
        mRvContent.setNestedScrollingEnabled(false);
        mRvContent.setFocusable(false);
        mPresenter.initView();
    }

    @Override
    public void initData() {
        super.initData();
//        mPresenter.initData();
        String type = getIntent().getStringExtra(AppConst.TYPE);
        if(type.equals("3")){
            mPresenter.getCompensate();
            mLlRZTZ.setVisibility(View.GONE);
            mLlAmount.setVisibility(View.VISIBLE);
        }else{
            mPresenter.getCheckIn();
            mLlRZTZ.setVisibility(View.VISIBLE);
            mLlAmount.setVisibility(View.GONE);
        }

        if(getIntent().getStringExtra(AppConst.STATE).equals("1")){
            mPresenter.isFinish = true;
            mLlRZTZ.setVisibility(View.GONE);
            mLlAmount.setVisibility(View.GONE);
            mPresenter.showBtnUi();
        }

    }

    @Override
    public void initListener() {
        super.initListener();
        mTvCheckOver.setOnClickListener(v -> mPresenter.checkOver());
    }

    @Override
    public RecyclerView getRvContent() {
        return mRvContent;
    }

    @Override
    public TextView getTvCheckOver() {
        return mTvCheckOver;
    }

    @Override
    public EditText getEtOtherexplain() {
        return mEtOtherexplain;
    }

    @Override
    public EditText getEtHygieneexplain() {
        return mEtHygieneexplain;
    }

    @Override
    public EditText getEtAmount() {
        return mEtAmount;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        mPresenter.onActivityResult(requestCode, resultCode, data);
    }
}
